import pandas as pd
from pyecharts import options as opts
from pyecharts.charts import Map

# 读取csv文件
map_data = pd.read_csv('../reptile/url.csv', encoding="utf-8")
# 获取location列的数据
data = map_data[["city","sum"]].values.tolist()

# 创建Map对象
map = Map(init_opts=opts.InitOpts(
    width='80%',
    height='600px',
    page_title="地图",
    theme = "white"
))

# 添加数据
map.add(series_name="", 
        data_pair=list(data), 
        maptype="china", 
        itemstyle_opts=opts.ItemStyleOpts(color='#A60B63',border_color='#FFFF22')
)

map.set_global_opts(
    visualmap_opts=opts.VisualMapOpts(
        max_= 414, 
        split_number=8, 
        is_piecewise=True
    ),
)

# 渲染地图
map.render("../webapp/templates/map.html")
